﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using YArchitech.BIM;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HYSpace
{
	public partial class FrmShowInfo : System.Windows.Forms.Form
	{
		public FrmShowInfo()
		{
			this.InitializeComponent();
			this.SetTreeViewFocus(this.tvSpaceClass);
			this.SetUCPanelTextEvent();
		}

		public FrmShowInfo(int roomTypeId, string operate)
		{
			this.InitializeComponent();
			this.SetTreeViewFocus(this.tvSpaceClass);
			this.SetUCPanelTextEvent();
			this.rTypeId = roomTypeId;
			this.btnOperate = operate;
		}

		private void FrmShowInfo_Load(object sender, EventArgs e)
		{
			this.isInit = true;
			base.Icon = Resource.YArchitechIcon;
			this.btnAdd.Image = Resources.AddNew16;
			this.btnModify.Image = Resources.modify16;
			this.btnDelete.Image = Resources.delete16;
			this.SetTreeViewFocus(this.tvSpaceClass);
			this.loadParam = new LoadParamOperate();
			FrmShowInfo.listSPI = this.loadParam.GetAllSpaceInfo();
			FrmShowInfo.listTAssign = this.loadParam.GetAllTimeInfo();
			this.InitialInterface(FrmShowInfo.listSPI, 0, 0);
			if (this.rTypeId > 0)
			{
				string b = "";
				int parentNum = 0;
				int childNum = 0;
				foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
				{
					if (spaceParameterInfo.RoomId == this.rTypeId)
					{
						b = spaceParameterInfo.RoomName;
					}
				}
				foreach (object obj in this.tvSpaceClass.Nodes)
				{
					foreach (object obj2 in ((TreeNode)obj).Nodes)
					{
						TreeNode treeNode = (TreeNode)obj2;
						if (treeNode.Text == b)
						{
							parentNum = treeNode.Parent.Index;
							childNum = treeNode.Index;
						}
					}
				}
				this.InitialInterface(FrmShowInfo.listSPI, parentNum, childNum);
			}
			this.SetUCPanelCmbEvent();
			foreach (SpaceParameterInfo spaceParameterInfo2 in FrmShowInfo.listSPI)
			{
				spaceParameterInfo2.Operation = "无操作";
			}
			this.SetToolTipUcSpace();
		}

		private void SetToolTipUcSpace()
		{
			this.ucSpaceParameter1.cmbXinFengSJB.MouseHover += this.cmbXinFengSJB_MouseHover;
			this.ucSpaceParameter1.cmbRenYuanSJB.MouseHover += this.cmbXinFengSJB_MouseHover;
			this.ucSpaceParameter1.cmbZhaoMingSJB.MouseHover += this.cmbXinFengSJB_MouseHover;
			this.ucSpaceParameter1.cmbDianDongSBSJB.MouseHover += this.cmbXinFengSJB_MouseHover;
			this.ucSpaceParameter1.cmbDianReSBSJB.MouseHover += this.cmbXinFengSJB_MouseHover;
			this.ucSpaceParameter1.cmbDianZiSBSJB.MouseHover += this.cmbXinFengSJB_MouseHover;
		}

		private void cmbXinFengSJB_MouseHover(object sender, EventArgs e)
		{
			ComboBox comboBox = (ComboBox)sender;
			this.toolTip1.SetToolTip(comboBox, comboBox.SelectedItem.ToString());
		}

		private void InitialInterface(IList<SpaceParameterInfo> listSPI, int parentNum, int childNum)
		{
			IList<int> list = new List<int>();
			foreach (SpaceParameterInfo spaceParameterInfo in listSPI)
			{
				if (!list.Contains(spaceParameterInfo.RoomTypeId))
				{
					TreeNode treeNode = TreeViewTools.CreatTreeViewNode(spaceParameterInfo.RoomTypeName, spaceParameterInfo.RoomTypeId.ToString());
					list.Add(spaceParameterInfo.RoomTypeId);
					foreach (SpaceParameterInfo spaceParameterInfo2 in listSPI)
					{
						if (spaceParameterInfo.RoomTypeName == spaceParameterInfo2.RoomTypeName)
						{
							TreeNode treeNode2 = TreeViewTools.CreatTreeViewNode(spaceParameterInfo2.RoomName, spaceParameterInfo2.RoomId.ToString());
							treeNode2.Name = spaceParameterInfo2.RoomId.ToString();
							treeNode.Nodes.Add(treeNode2);
						}
					}
					this.tvSpaceClass.Nodes.Add(treeNode);
				}
			}
			this.tvSpaceClass.SelectedNode = this.tvSpaceClass.Nodes[parentNum].Nodes[childNum];
			this.tvSpaceClass.Select();
			this.tvSpaceClass.Focus();
			int num = Convert.ToInt32(this.tvSpaceClass.SelectedNode.Name);
			foreach (SpaceParameterInfo spaceParameterInfo3 in listSPI)
			{
				if (spaceParameterInfo3.RoomId == num)
				{
					this.BandGBXInfo(spaceParameterInfo3);
					break;
				}
			}
			if (this.isInit)
			{
				this.isInit = false;
			}
		}

		public void BandGBXInfo(SpaceParameterInfo spi)
		{
			this.ucSpaceParameter1.Tag = spi.RoomId;
			this.BandCMBDataSource(FrmShowInfo.listTAssign);
			foreach (object obj in this.ucSpaceParameter1.Controls)
			{
				TextBox textBox = obj as TextBox;
				if (textBox != null)
				{
					foreach (SpacePara spacePara in spi.Param)
					{
						if (textBox.Tag.ToString() == spacePara.Key)
						{
							string value = spacePara.Value;
							if (spacePara.Key == "人员总数" || spacePara.Key == "噪音" || spacePara.Key == "用水量标准")
							{
								textBox.Text = value;
							}
							else
							{
								textBox.Text = StringTools.CutOffEfficacious(value, 2);
							}
						}
					}
				}
				ComboBox comboBox = obj as ComboBox;
				if (comboBox != null)
				{
					foreach (SpacePara spacePara2 in spi.Param)
					{
						if (comboBox.Tag.ToString() == spacePara2.Key)
						{
							if (spacePara2.Key == "劳动强度(enum)")
							{
								int selectedIndex = (int)Enum.Parse(typeof(LaborIntensity), spacePara2.Value);
								comboBox.SelectedIndex = selectedIndex;
							}
							else
							{
								comboBox.SelectedItem = this.GetCMBVaule(FrmShowInfo.listTAssign, spacePara2.Value);
							}
						}
					}
				}
			}
		}

		private void btnExit_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void tvSpaceUse_DrawNode(object sender, DrawTreeNodeEventArgs e)
		{
			e.DrawDefault = true;
			if ((e.State & TreeNodeStates.Selected) != (TreeNodeStates)0)
			{
				e.Graphics.FillRectangle(Brushes.DarkBlue, e.Node.Bounds);
				Font font = e.Node.NodeFont;
				if (font == null)
				{
					font = ((TreeView)sender).Font;
				}
				e.Graphics.DrawString(e.Node.Text, font, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
			}
			else
			{
				e.DrawDefault = true;
			}
			if ((e.State & TreeNodeStates.Focused) != (TreeNodeStates)0)
			{
				using (Pen pen = new Pen(Color.Black))
				{
					pen.DashStyle = DashStyle.Dot;
					Rectangle bounds = e.Node.Bounds;
					bounds.Size = new Size(bounds.Width - 1, bounds.Height - 1);
					e.Graphics.DrawRectangle(pen, bounds);
				}
			}
		}

		private void SetTreeViewFocus(TreeView tv)
		{
			tv.HideSelection = false;
			tv.DrawMode = TreeViewDrawMode.OwnerDrawText;
			tv.DrawNode += this.tvSpaceUse_DrawNode;
		}

		private void tvSpaceClass_AfterSelect(object sender, TreeViewEventArgs e)
		{
			try
			{
				this.isTreeChange = true;
				if (this.tvSpaceClass.SelectedNode.Parent != null)
				{
					foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
					{
						if (this.tvSpaceClass.SelectedNode.Tag.ToString() == spaceParameterInfo.RoomId.ToString())
						{
							this.BandGBXInfo(spaceParameterInfo);
						}
					}
				}
				this.isTreeChange = false;
			}
			catch (Exception)
			{
				this.isTreeChange = false;
				throw;
			}
		}

		private void BandCMBDataSource(IList<TimeAssign> listTA)
		{
			List<TimeAssign> list = new List<TimeAssign>();
			List<TimeAssign> list2 = new List<TimeAssign>();
			List<TimeAssign> list3 = new List<TimeAssign>();
			List<TimeAssign> list4 = new List<TimeAssign>();
			List<TimeAssign> list5 = new List<TimeAssign>();
			List<TimeAssign> list6 = new List<TimeAssign>();
			this.ucSpaceParameter1.cmbRenYuanSJB.Items.Clear();
			this.ucSpaceParameter1.cmbDianReSBSJB.Items.Clear();
			this.ucSpaceParameter1.cmbDianZiSBSJB.Items.Clear();
			this.ucSpaceParameter1.cmbDianDongSBSJB.Items.Clear();
			this.ucSpaceParameter1.cmbZhaoMingSJB.Items.Clear();
			this.ucSpaceParameter1.cmbXinFengSJB.Items.Clear();
			foreach (TimeAssign timeAssign in listTA)
			{
				string tsParent = timeAssign.TsParent;
				if (!(tsParent == "人员"))
				{
					if (!(tsParent == "新风"))
					{
						if (!(tsParent == "照明"))
						{
							if (!(tsParent == "电动设备"))
							{
								if (!(tsParent == "电子设备"))
								{
									if (tsParent == "电热设备")
									{
										list6.Add(timeAssign);
										this.ucSpaceParameter1.cmbDianReSBSJB.Items.Add(timeAssign.TsName);
									}
								}
								else
								{
									list5.Add(timeAssign);
									this.ucSpaceParameter1.cmbDianZiSBSJB.Items.Add(timeAssign.TsName);
								}
							}
							else
							{
								list4.Add(timeAssign);
								this.ucSpaceParameter1.cmbDianDongSBSJB.Items.Add(timeAssign.TsName);
							}
						}
						else
						{
							list2.Add(timeAssign);
							this.ucSpaceParameter1.cmbZhaoMingSJB.Items.Add(timeAssign.TsName);
						}
					}
					else
					{
						list3.Add(timeAssign);
						this.ucSpaceParameter1.cmbXinFengSJB.Items.Add(timeAssign.TsName);
					}
				}
				else
				{
					list.Add(timeAssign);
					this.ucSpaceParameter1.cmbRenYuanSJB.Items.Add(timeAssign.TsName);
				}
			}
		}

		private string GetCMBVaule(IList<TimeAssign> listTA, string paraValue)
		{
			string result = paraValue;
			List<TimeAssign> list = new List<TimeAssign>();
			List<TimeAssign> list2 = new List<TimeAssign>();
			List<TimeAssign> list3 = new List<TimeAssign>();
			List<TimeAssign> list4 = new List<TimeAssign>();
			List<TimeAssign> list5 = new List<TimeAssign>();
			List<TimeAssign> list6 = new List<TimeAssign>();
			foreach (TimeAssign timeAssign in listTA)
			{
				string tsParent = timeAssign.TsParent;
				if (!(tsParent == "人员"))
				{
					if (!(tsParent == "新风"))
					{
						if (!(tsParent == "照明"))
						{
							if (!(tsParent == "电动设备"))
							{
								if (!(tsParent == "电子设备"))
								{
									if (tsParent == "电热设备")
									{
										list6.Add(timeAssign);
									}
								}
								else
								{
									list5.Add(timeAssign);
								}
							}
							else
							{
								list4.Add(timeAssign);
							}
						}
						else
						{
							list2.Add(timeAssign);
						}
					}
					else
					{
						list3.Add(timeAssign);
					}
				}
				else
				{
					list.Add(timeAssign);
				}
			}
			if (paraValue.Contains("人员"))
			{
				result = this.CMBValue(list, paraValue);
			}
			if (paraValue.Contains("新风"))
			{
				result = this.CMBValue(list3, paraValue);
			}
			if (paraValue.Contains("照明"))
			{
				result = this.CMBValue(list2, paraValue);
			}
			if (paraValue.Contains("电动设备"))
			{
				result = this.CMBValue(list4, paraValue);
			}
			if (paraValue.Contains("电子设备"))
			{
				result = this.CMBValue(list5, paraValue);
			}
			if (paraValue.Contains("电热设备"))
			{
				result = this.CMBValue(list6, paraValue);
			}
			return result;
		}

		private string CMBValue(IList<TimeAssign> listTA, string paraValue)
		{
			string text = "";
			foreach (TimeAssign timeAssign in listTA)
			{
				if (paraValue == timeAssign.TsName)
				{
					text = timeAssign.TsName;
					break;
				}
			}
			if (text == "")
			{
				text = listTA[0].TsName;
			}
			return text;
		}

		private void SetCMBTimeItem(TimeAssign[] selectedItem)
		{
			foreach (TimeAssign timeAssign in selectedItem)
			{
				string tsParent = timeAssign.TsParent;
				if (!(tsParent == "人员"))
				{
					if (!(tsParent == "新风"))
					{
						if (!(tsParent == "照明"))
						{
							if (!(tsParent == "电动设备"))
							{
								if (!(tsParent == "电子设备"))
								{
									if (tsParent == "电热设备")
									{
										this.ucSpaceParameter1.cmbDianReSBSJB.SelectedItem = timeAssign.TsName;
									}
								}
								else
								{
									this.ucSpaceParameter1.cmbDianZiSBSJB.SelectedItem = timeAssign.TsName;
								}
							}
							else
							{
								this.ucSpaceParameter1.cmbDianDongSBSJB.SelectedItem = timeAssign.TsName;
							}
						}
						else
						{
							this.ucSpaceParameter1.cmbZhaoMingSJB.SelectedItem = timeAssign.TsName;
						}
					}
					else
					{
						this.ucSpaceParameter1.cmbXinFengSJB.SelectedItem = timeAssign.TsName;
					}
				}
				else
				{
					this.ucSpaceParameter1.cmbRenYuanSJB.SelectedItem = timeAssign.TsName;
				}
			}
		}

		private void btnDelete_Click(object sender, EventArgs e)
		{
			if (this.tvSpaceClass.SelectedNode.Parent == null)
			{
				return;
			}
			if (this.tvSpaceClass.SelectedNode.Parent.Nodes.Count <= 1)
			{
				return;
			}
			if (YJKMessageBox.Show("确认要删除数据？", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				bool flag = false;
				int parentNum = 0;
				int num = 0;
				parentNum = this.tvSpaceClass.SelectedNode.Parent.Index;
				num = this.tvSpaceClass.SelectedNode.Index;
				SpaceParameterInfo item = new SpaceParameterInfo();
				foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
				{
					if (!(this.tvSpaceClass.SelectedNode.Tag.ToString() != spaceParameterInfo.RoomId.ToString()))
					{
						flag = this.loadParam.DeleteSpaceParameterByRoomUse(spaceParameterInfo.RoomId);
						item = spaceParameterInfo;
					}
				}
				if (flag)
				{
					FrmShowInfo.listSPI.Remove(item);
					YJKMessageBox.Show("删除成功！");
					this.tvSpaceClass.Nodes.Clear();
					this.isInit = true;
					this.isTreeChange = true;
					this.InitialInterface(FrmShowInfo.listSPI, parentNum, num - 1);
				}
			}
		}

		private void btnModify_Click(object sender, EventArgs e)
		{
			if (this.tvSpaceClass.SelectedNode.Parent == null)
			{
				return;
			}
			int index = this.tvSpaceClass.SelectedNode.Parent.Index;
			int index2 = this.tvSpaceClass.SelectedNode.Index;
			this.tvSpaceClass.LabelEdit = false;
			int num = Convert.ToInt32(this.tvSpaceClass.SelectedNode.Tag);
			FrmModifyRoomName frmModifyRoomName = new FrmModifyRoomName(num);
			if (frmModifyRoomName.ShowDialog() == DialogResult.Yes)
			{
				new LoadCirculation();
				foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
				{
					if (num == spaceParameterInfo.RoomId)
					{
						spaceParameterInfo.RoomName = frmModifyRoomName.roomName;
						if (spaceParameterInfo.Operation != "添加")
						{
							spaceParameterInfo.Operation = "修改";
							break;
						}
						break;
					}
				}
			}
			this.tvSpaceClass.Nodes.Clear();
			this.InitialInterface(FrmShowInfo.listSPI, index, index2);
		}

		private void btnAdd_Click(object sender, EventArgs e)
		{
			int num = 0;
			int num2;
			if (this.tvSpaceClass.SelectedNode.Parent == null)
			{
				num2 = Convert.ToInt32(this.tvSpaceClass.SelectedNode.Tag);
				num = this.tvSpaceClass.SelectedNode.Index;
			}
			else
			{
				num2 = Convert.ToInt32(this.tvSpaceClass.SelectedNode.Parent.Tag);
				num = this.tvSpaceClass.SelectedNode.Parent.Index;
				int childNum = this.tvSpaceClass.SelectedNode.Index;
			}
			if (num2 > 0)
			{
				FrmAddRoomName frmAddRoomName = new FrmAddRoomName(num2);
				if (frmAddRoomName.ShowDialog() == DialogResult.Yes)
				{
					SpaceParameterInfo spaceParameterInfo = new SpaceParameterInfo();
					foreach (SpaceParameterInfo spaceParameterInfo2 in FrmShowInfo.listSPI)
					{
						if (frmAddRoomName.roomTID == spaceParameterInfo2.RoomTypeId)
						{
							int num3 = this.loadParam.GetMaxUseID();
							foreach (SpaceParameterInfo spaceParameterInfo3 in FrmShowInfo.listSPI)
							{
								if (spaceParameterInfo3.RoomId > num3)
								{
									num3 = spaceParameterInfo3.RoomId;
								}
							}
							spaceParameterInfo.RoomId = num3 + 1;
							spaceParameterInfo.Operation = "添加";
							spaceParameterInfo.RoomName = frmAddRoomName.roomName;
							spaceParameterInfo.Param = new List<SpacePara>();
							foreach (SpacePara spacePara in spaceParameterInfo2.Param)
							{
								SpacePara spacePara2 = new SpacePara();
								spacePara2.Key = spacePara.Key;
								spacePara2.Value = spacePara.Value;
								spaceParameterInfo.Param.Add(spacePara2);
							}
							spaceParameterInfo.RoomTypeId = spaceParameterInfo2.RoomTypeId;
							spaceParameterInfo.RoomTypeName = spaceParameterInfo2.RoomTypeName;
							foreach (object obj in this.tvSpaceClass.Nodes)
							{
								TreeNode treeNode = (TreeNode)obj;
								if (treeNode.Nodes.Count > 0 && treeNode.Text == spaceParameterInfo2.RoomTypeName)
								{
									num = treeNode.Index;
									break;
								}
							}
						}
					}
					FrmShowInfo.listSPI.Add(spaceParameterInfo);
					int childNum = this.tvSpaceClass.Nodes[num].Nodes.Count;
					this.tvSpaceClass.Nodes.Clear();
					this.InitialInterface(FrmShowInfo.listSPI, num, childNum);
					this.tvSpaceClass.LabelEdit = false;
				}
			}
		}

		public void Text_Leave(object sender, EventArgs e)
		{
			foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
			{
				if (spaceParameterInfo.RoomId == Convert.ToInt32(this.ucSpaceParameter1.Tag))
				{
					TextBox textBox = (TextBox)sender;
					if (string.IsNullOrEmpty(textBox.Text))
					{
						break;
					}
					if (textBox.Text == ".")
					{
						textBox.Text = "0";
					}
					if (spaceParameterInfo.Operation != "添加" && !this.isTreeChange && !this.isInit)
					{
						spaceParameterInfo.Operation = "修改";
					}
					foreach (SpacePara spacePara in spaceParameterInfo.Param)
					{
						if (textBox.Tag.ToString() == spacePara.Key)
						{
							spacePara.Value = textBox.Text;
						}
					}
				}
			}
		}

		private void SetUCPanelTextEvent()
		{
			foreach (object obj in this.ucSpaceParameter1.Controls)
			{
				TextBox textBox = obj as TextBox;
				if (textBox != null)
				{
					textBox.TextChanged += this.Text_Leave;
				}
				ComboBox comboBox = obj as ComboBox;
				if (comboBox != null)
				{
					comboBox.SelectedIndexChanged += this.Cmb_ValueChanged;
				}
			}
		}

		private void Cmb_ValueChanged(object sender, EventArgs e)
		{
			foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
			{
				if (spaceParameterInfo.RoomId == Convert.ToInt32(this.ucSpaceParameter1.Tag))
				{
					ComboBox comboBox = (ComboBox)sender;
					if (spaceParameterInfo.Operation != "添加" && !this.isTreeChange && !this.isInit)
					{
						spaceParameterInfo.Operation = "修改";
					}
					foreach (SpacePara spacePara in spaceParameterInfo.Param)
					{
						if (comboBox.Tag.ToString() == spacePara.Key)
						{
							if (spacePara.Key == "劳动强度(enum)")
							{
								spacePara.Value = comboBox.SelectedIndex.ToString();
							}
							else
							{
								spacePara.Value = Convert.ToString(comboBox.SelectedItem);
							}
						}
					}
				}
			}
		}

		private void SetUCPanelCmbEvent()
		{
			this.ucSpaceParameter1.btnDianDongSBSJB.Click += this.ShowTimeInfo;
			this.ucSpaceParameter1.btnDianReSBSJB.Click += this.ShowTimeInfo;
			this.ucSpaceParameter1.btnDianZiSBSJB.Click += this.ShowTimeInfo;
			this.ucSpaceParameter1.btnRenYuanSJB.Click += this.ShowTimeInfo;
			this.ucSpaceParameter1.btnXinFengSJB.Click += this.ShowTimeInfo;
			this.ucSpaceParameter1.btnZhaoMingSJB.Click += this.ShowTimeInfo;
		}

		private void btnSave_Click(object sender, EventArgs e)
		{
			if (this.JudgeWDInfo())
			{
				return;
			}
			if (this.tvSpaceClass.SelectedNode.Parent == null)
			{
				return;
			}
			int index = this.tvSpaceClass.SelectedNode.Parent.Index;
			int index2 = this.tvSpaceClass.SelectedNode.Index;
			int num = 0;
			int num2 = 0;
			foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
			{
				if (Convert.ToInt32(this.tvSpaceClass.SelectedNode.Tag) == spaceParameterInfo.RoomId)
				{
					string operation = spaceParameterInfo.Operation;
					if (!(operation == "添加"))
					{
						if (!(operation == "修改"))
						{
							break;
						}
						if (this.loadParam.UpdateSpaceParameterInfo(spaceParameterInfo))
						{
							num2++;
							spaceParameterInfo.Operation = "无操作";
							break;
						}
						break;
					}
					else
					{
						int num3 = this.loadParam.GetMaxUseID();
						foreach (SpaceParameterInfo spaceParameterInfo2 in FrmShowInfo.listSPI)
						{
							if (spaceParameterInfo2.RoomId > num3)
							{
								num3 = spaceParameterInfo2.RoomId;
							}
						}
						spaceParameterInfo.RoomId = num3;
						num3 = this.loadParam.GetMaxLoadID();
						foreach (SpaceParameterInfo spi in FrmShowInfo.listSPI)
						{
							SpaceLoadParameter spaceLoadParameter = this.loadParam.TranformSpaceInfo(spi);
							if (spaceLoadParameter.Id > num3)
							{
								num3 = spaceLoadParameter.Id;
							}
						}
						if (this.loadParam.AddSpaceParameterInfo(spaceParameterInfo, num3))
						{
							num++;
							spaceParameterInfo.Operation = "无操作";
							break;
						}
						break;
					}
				}
			}
			this.tvSpaceClass.Nodes.Clear();
			this.isInit = true;
			this.isTreeChange = true;
			this.InitialInterface(FrmShowInfo.listSPI, index, index2);
			if (num > 0 || num2 > 0)
			{
				string message = "";
				if (num > 0 || num2 > 0)
				{
					message = "当前页面信息保存成功！";
				}
				YJKMessageBox.Show(message);
			}
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			if (this.JudgeWDInfo())
			{
				return;
			}
			int parentNum = 0;
			int childNum = 0;
			if (this.tvSpaceClass.SelectedNode.Parent == null)
			{
				parentNum = this.tvSpaceClass.SelectedNode.Index;
				childNum = 0;
			}
			else
			{
				parentNum = this.tvSpaceClass.SelectedNode.Parent.Index;
				childNum = this.tvSpaceClass.SelectedNode.Index;
			}
			int num = 0;
			int num2 = 0;
			foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
			{
				string operation = spaceParameterInfo.Operation;
				if (!(operation == "添加"))
				{
					if (operation == "修改")
					{
						if (this.loadParam.UpdateSpaceParameterInfo(spaceParameterInfo))
						{
							num2++;
							spaceParameterInfo.Operation = "无操作";
						}
					}
				}
				else
				{
					int num3 = this.loadParam.GetMaxLoadID();
					foreach (SpaceParameterInfo spi in FrmShowInfo.listSPI)
					{
						SpaceLoadParameter spaceLoadParameter = this.loadParam.TranformSpaceInfo(spi);
						if (spaceLoadParameter.Id > num3)
						{
							num3 = spaceLoadParameter.Id;
						}
					}
					if (this.loadParam.AddSpaceParameterInfo(spaceParameterInfo, num3 + 1))
					{
						num++;
						spaceParameterInfo.Operation = "无操作";
					}
				}
			}
			this.tvSpaceClass.Nodes.Clear();
			this.isInit = true;
			this.isTreeChange = true;
			this.InitialInterface(FrmShowInfo.listSPI, parentNum, childNum);
			if (num > 0 || num2 > 0)
			{
				string text = "";
				if (num > 0)
				{
					text = string.Concat(new object[]
					{
						text,
						"添加",
						num,
						"条数据"
					});
				}
				if (!string.IsNullOrEmpty(text))
				{
					text += "\n";
				}
				if (num2 > 0)
				{
					text = string.Concat(new object[]
					{
						text,
						"修改",
						num2,
						"条数据"
					});
				}
				YJKMessageBox.Show(text);
			}
			if (this.btnOperate == "CONTINUE")
			{
				if (this.tvSpaceClass.SelectedNode.Parent == null)
				{
					return;
				}
				foreach (SpaceParameterInfo spaceParameterInfo2 in FrmShowInfo.listSPI)
				{
					if (this.tvSpaceClass.SelectedNode.Tag.ToString() == spaceParameterInfo2.RoomId.ToString())
					{
						this.selRoomId = spaceParameterInfo2.RoomId;
					}
				}
				base.DialogResult = DialogResult.Yes;
			}
			base.Close();
		}

		private void ShowTimeInfo(object sender, EventArgs e)
		{
			string nodeText = "";
			string a = ((Button)sender).Name;
			if (!(a == "btnDianDongSBSJB"))
			{
				if (!(a == "btnDianReSBSJB"))
				{
					if (!(a == "btnDianZiSBSJB"))
					{
						if (!(a == "btnRenYuanSJB"))
						{
							if (!(a == "btnXinFengSJB"))
							{
								if (a == "btnZhaoMingSJB")
								{
									nodeText = this.ucSpaceParameter1.cmbZhaoMingSJB.SelectedItem.ToString();
								}
							}
							else
							{
								nodeText = this.ucSpaceParameter1.cmbXinFengSJB.SelectedItem.ToString();
							}
						}
						else
						{
							nodeText = this.ucSpaceParameter1.cmbRenYuanSJB.SelectedItem.ToString();
						}
					}
					else
					{
						nodeText = this.ucSpaceParameter1.cmbDianZiSBSJB.SelectedItem.ToString();
					}
				}
				else
				{
					nodeText = this.ucSpaceParameter1.cmbDianReSBSJB.SelectedItem.ToString();
				}
			}
			else
			{
				nodeText = this.ucSpaceParameter1.cmbDianDongSBSJB.SelectedItem.ToString();
			}
			foreach (TimeAssign timeAssign in FrmShowInfo.listTAssign)
			{
				a = timeAssign.TsParent;
				if (!(a == "人员"))
				{
					if (!(a == "新风"))
					{
						if (!(a == "照明"))
						{
							if (!(a == "电动设备"))
							{
								if (!(a == "电子设备"))
								{
									if (a == "电热设备")
									{
										if (this.ucSpaceParameter1.cmbDianReSBSJB.SelectedItem.ToString() == timeAssign.TsName)
										{
											FrmShowInfo.selectedItem[5] = timeAssign;
										}
									}
								}
								else if (this.ucSpaceParameter1.cmbDianZiSBSJB.SelectedItem.ToString() == timeAssign.TsName)
								{
									FrmShowInfo.selectedItem[4] = timeAssign;
								}
							}
							else if (this.ucSpaceParameter1.cmbDianDongSBSJB.SelectedItem.ToString() == timeAssign.TsName)
							{
								FrmShowInfo.selectedItem[3] = timeAssign;
							}
						}
						else if (this.ucSpaceParameter1.cmbZhaoMingSJB.SelectedItem.ToString() == timeAssign.TsName)
						{
							FrmShowInfo.selectedItem[2] = timeAssign;
						}
					}
					else if (this.ucSpaceParameter1.cmbXinFengSJB.SelectedItem.ToString() == timeAssign.TsName)
					{
						FrmShowInfo.selectedItem[1] = timeAssign;
					}
				}
				else if (this.ucSpaceParameter1.cmbRenYuanSJB.SelectedItem.ToString() == timeAssign.TsName)
				{
					FrmShowInfo.selectedItem[0] = timeAssign;
				}
			}
			if (new FrmTimeAssignManage(nodeText, FrmShowInfo.listTAssign).ShowDialog() == DialogResult.OK)
			{
				this.BandCMBDataSource(FrmShowInfo.listTAssign);
				foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
				{
					if (Convert.ToInt32(this.tvSpaceClass.SelectedNode.Tag) == spaceParameterInfo.RoomId)
					{
						this.BandGBXInfo(spaceParameterInfo);
					}
				}
				this.ucSpaceParameter1.cmbRenYuanSJB.SelectedItem = FrmShowInfo.selectedItem[0].TsName;
				this.ucSpaceParameter1.cmbXinFengSJB.SelectedItem = FrmShowInfo.selectedItem[1].TsName;
				this.ucSpaceParameter1.cmbZhaoMingSJB.SelectedItem = FrmShowInfo.selectedItem[2].TsName;
				this.ucSpaceParameter1.cmbDianDongSBSJB.SelectedItem = FrmShowInfo.selectedItem[3].TsName;
				this.ucSpaceParameter1.cmbDianZiSBSJB.SelectedItem = FrmShowInfo.selectedItem[4].TsName;
				this.ucSpaceParameter1.cmbDianReSBSJB.SelectedItem = FrmShowInfo.selectedItem[5].TsName;
			}
		}

		private bool JudgeWDInfo()
		{
			bool result = false;
			double num = Convert.ToDouble(this.ucSpaceParameter1.txtDongJiKTSJWD.Text);
			double num2 = Convert.ToDouble(this.ucSpaceParameter1.txtXiaJiKTSJWD.Text);
			double num3 = Convert.ToDouble(this.ucSpaceParameter1.txtDongJiCNSJWD.Text);
			if (num < 13.0 || num > 113.0)
			{
				YJKMessageBox.Show("设计温度应该在13-113间");
				this.ucSpaceParameter1.txtDongJiKTSJWD.Select();
				return true;
			}
			if (num2 < 13.0 || num2 > 113.0)
			{
				YJKMessageBox.Show("设计温度应该在13-113间");
				this.ucSpaceParameter1.txtXiaJiKTSJWD.Select();
				return true;
			}
			if (num3 < 13.0 || num3 > 113.0)
			{
				YJKMessageBox.Show("设计温度应该在13-113间");
				this.ucSpaceParameter1.txtDongJiCNSJWD.Select();
				return true;
			}
			return result;
		}

		public static IList<SpaceParameterInfo> listSPI = new List<SpaceParameterInfo>();

		public static IList<TimeAssign> listTAssign = new List<TimeAssign>();

		private int rTypeId;

		private string btnOperate = "NOT";

		public int selRoomId;

		private bool isTreeChange = true;

		private bool isInit;

		public static TimeAssign[] selectedItem = new TimeAssign[6];

		private LoadParamOperate loadParam;
	}
}
